package com.qf.j2105.controller;

import com.qf.j2105.po.UserInfo;
import com.qf.j2105.service.UserInfoService;
import com.qf.j2105.vo.LoginInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Slf4j
public class UserInfoCOntroller {

    @Autowired
    private UserInfoService userInfoService;

    //登录
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    @ResponseBody
    public UserInfo login( LoginInfoVo loginInfo) {

        System.out.println("loginInfo = " + loginInfo);
        UserInfo login = userInfoService.login(loginInfo);
        return login;
    }

    //注册
    @RequestMapping(value = "/regist", method = RequestMethod.POST)
    @ResponseBody
    public String regist(UserInfo userInfo) {
        boolean insert = userInfoService.insert(userInfo);

        if (insert) {
            return "注册成功";
        } else {
            return "注册失败";
        }

    }
}
